package com.trg.designmodel.singleleton;

/**
 * @ClassName: SingleLetonTest08
 * @Description:    单例设计模式-枚举
 * @Author: tangrg
 * @Date: 2021/6/30 17:26
 * @Version: 1.0
 * @Return:
 **/
public class SingleLetonTest08 {

    public static void main(String[] args) {
        SingleLeton08 instance = SingleLeton08.INSTANCE;
        SingleLeton08 instance2 = SingleLeton08.INSTANCE;
        System.out.println("单例设计模式-枚举");
        System.out.println(instance == instance2);
        System.out.println("instance:" + instance.hashCode());
        System.out.println("instance2:" + instance2.hashCode());
        instance2.say();

    }
}

enum  SingleLeton08{
    INSTANCE;
    public void say(){
        System.out.println("OK");
    }


}

